package com.shop2cn.iapi.agentproducts.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.DeleteActivityBean;
import com.shop2cn.iapi.agentproducts.service.DeleteActivityCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallServiceV2;
/**
*代理商移除特卖活动Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_DeleteActivity{
	private static DeleteActivityBean deleteactivityBean;
	private static DeleteActivityCall deleteactivityCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("代理商移除特卖活动Test");
	}

	@Before
	public void caseUp() {
		deleteactivityBean=new DeleteActivityBean();
		deleteactivityCall=new DeleteActivityCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(deleteactivityCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_DeleteActivity_001() {
		Logger.start(true,"正确数据，成功");
		try {
			int rootUserId = 501428441;
			int agentUserId = 501428443;
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					"", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建限时抢活动
			AddactivityBean initProductaddactivity = AgentProductCallServiceV2.initAgenttActivity(rootUserId, productId,1,30);
			Integer activityId = AgentProductCallServiceV2.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(3000);
			AgentProductCallServiceV2.ImportProductByActivityId(agentUserId, activityId);
			Thread.sleep(3000);
			JsonObject activityList = AgentProductCallServiceV2.ActivityList(agentUserId);
			Logger.verifyEquals(true, activityList.toString().indexOf(""+activityId)!=-1, "验证查询到了活动id");
			Thread.sleep(3000);
			deleteactivityBean.setUserId(agentUserId);
			deleteactivityBean.setActivityId(activityId);
			deleteactivityCall.setData(deleteactivityBean);
			deleteactivityCall.callService();
			Logger.verifyEquals("200", deleteactivityCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}